<?php	
	// Interface function	
	function oh_module_action($tokens) {
		global $oh_object_action;
		$oh_object_action->last_action = implode("-",$tokens);
		return $oh_object_action;
	} 

	// Option file required
	//require_once($oh['path']."/modules/mysql/ezsql/shared/ez_sql_core.php");
	//require_once($oh['path']."/modules/mysql/ezsql/mysql/ez_sql_mysql.php");
	
	// Main class of module
	class oh_class_action {
		public $tabs_action;	
		public $last_action;
		function oh_class_action() {
			$this->action = array();
		}
		function raise($action = "") {
			foreach($this->tabs_action[$this->last_action] as $trigger) {
				$trigger['function']();	
			}					
		}
		function trigger($trigger) {
			$trigger = $this->parse_trigger($trigger);
			if (function_exists($trigger['function'])) {
				$this->tabs_action[$this->last_action][] = $trigger;				
			} else {
				oh_message("Function not found: ".$trigger['function'], "trigger");
			}
		}
		function parse_trigger($trigger) {
			$break = strpos($trigger,"?");
			if ($break === FALSE) {
				$output = array(
					'function' 		=> $trigger,
					'inline-args'	=> '',
				);
			} else {
				$output = array(
					'function' 		=> substr($trigger, 0, $break),
					'inline-args'	=> '',
				);
				parse_str(substr($trigger, $break+1), $inline_args);
				$output['inline-args'] = $inline_args;
			}
			return $output;
		}		
	}
	
	// Main object of module
	global $oh_object_action;
	$oh_object_action = new oh_class_action();
?>
